package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ImpPopZx;
import com.ruoyi.system.service.IImpPopZxService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 重点人口注销信息Controller
 * 
 * @author ruoyi
 * @date 2024-10-15
 */
@Controller
@RequestMapping("/system/zd_zx")
public class ImpPopZxController extends BaseController
{
    private String prefix = "system/zd_zx";

    @Autowired
    private IImpPopZxService impPopZxService;

    @RequiresPermissions("system:zd_zx:view")
    @GetMapping()
    public String zd_zx()
    {
        return prefix + "/zd_zx";
    }

    /**
     * 查询重点人口注销信息列表
     */
    @RequiresPermissions("system:zd_zx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ImpPopZx impPopZx)
    {
        startPage();
        List<ImpPopZx> list = impPopZxService.selectImpPopZxList(impPopZx);
        return getDataTable(list);
    }

    /**
     * 导出重点人口注销信息列表
     */
    @RequiresPermissions("system:zd_zx:export")
    @Log(title = "重点人口注销信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ImpPopZx impPopZx)
    {
        List<ImpPopZx> list = impPopZxService.selectImpPopZxList(impPopZx);
        ExcelUtil<ImpPopZx> util = new ExcelUtil<ImpPopZx>(ImpPopZx.class);
        return util.exportExcel(list, "重点人口注销信息数据");
    }

    /**
     * 新增重点人口注销信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存重点人口注销信息
     */
    @RequiresPermissions("system:zd_zx:add")
    @Log(title = "重点人口注销信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ImpPopZx impPopZx)
    {
        return toAjax(impPopZxService.insertImpPopZx(impPopZx));
    }

    /**
     * 修改重点人口注销信息
     */
    @RequiresPermissions("system:zd_zx:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ImpPopZx impPopZx = impPopZxService.selectImpPopZxById(id);
        mmap.put("impPopZx", impPopZx);
        return prefix + "/edit";
    }

    /**
     * 修改保存重点人口注销信息
     */
    @RequiresPermissions("system:zd_zx:edit")
    @Log(title = "重点人口注销信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ImpPopZx impPopZx)
    {
        return toAjax(impPopZxService.updateImpPopZx(impPopZx));
    }

    /**
     * 删除重点人口注销信息
     */
    @RequiresPermissions("system:zd_zx:remove")
    @Log(title = "重点人口注销信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(impPopZxService.deleteImpPopZxByIds(ids));
    }
}
